HAL DTS migration: List of applicable concepts

This section provides information about the HAL DTS applicable architecture concepts.

Concepts for DTS

Concept

Description

Separation of initialization and configuration functions

The initialization has been split into separate init and config functions:

  • HAL_DTS_Init(): initializes the DTS handle and links it to a DTS instance.

  • HAL_DTS_SetConfig(): sets the global configuration (reference clock, QuickMeasure, Divider if applicable).

  • HAL_DTS_SetConfigSensor(): sets per-sensor configuration (trigger source, sampling time).

  • HAL_DTS_SetConfigSensorThresholds(): sets per-sensor thresholds (high and low).

Removal and conversion of init structure to configuration structure

The legacy init structure is removed. Configuration is now provided through hal_dts_config_t and hal_dts_sensor_config_t used by the setter APIs. (need to add threshold that get configured with API).

Renaming of the handle structure

The handle structure has been renamed to hal_dts_handle_t.

Remove MspInit and MspDeInit callbacks

The functions HAL_DTS_MspInit() and HAL_DTS_MspDeInit() have been removed and replaced by a user-defined initialization sequence.

Unitary configuration APIs

New APIs have been introduced to get and set DTS features.

Introduction of HAL user data set/get APIs

Two functions are available to set and get user data: HAL_DTS_SetUserData() and HAL_DTS_GetUserData().

Individual callback registration APIs replace global register and unregister functions

The callback registration is handled by specific functions for each DTS event. These functions are used to register callback functions for different DTS events.

Introduce specialized IRQ handlers

Global HAL_DTS_IRQHandler is still available, no additional specialized public IRQ handlers are introduced. The internal implementation is logically segmented to process coherent event groups, reducing unnecessary flag checks and improving maintainability.

Revised and optimized HAL state machine

The DTS state machine now is split in :

  1. The DTS state machine

  2. The DTS sensor state machine

Revised and optimized HAL API status returns

The HAL DTS functions were updated to return:

  • HAL_INVALID_PARAM: in case of a NULL p_config structure pointer.

  • HAL_ERROR: in case of an error.

  • HAL_TIMEOUT: in case of a user timeout.

  • HAL_BUSY: in case of an ongoing process.

  • HAL_OK: in case of a successfully completed operation.

New APIs for filtering optional asynchronous process interrupts

Introduce HAL_DTS_StartSensor_IT_Opt function for optional Asynchronous interrupts.

Replaced TypeDef suffix with _t in type names

All TypeDef parts of the HAL DTS driver have been removed and replaced by _t.

Replaced nonmodifiable pointers with const keywords

Const keywords have been added to non-modifiable pointers to ensure that either the pointer itself or the data it points to cannot be modified. This enhances code safety and readability, prevents unintended modifications, and renders code more robust and maintainable.

Assertion implementation and usage in HAL1

The ASSERT_DBG_STATE and ASSERT_DBG_PARAM macros are used to check the parameters and state of the HAL DTS driver.

Remove EXTI Intrinsic Management in System HAL Drivers; Let Users Rely on EXTI HAL Driver.

EXTI handling is delegated to the EXTI HAL driver.

Add HAL PPP Services for Drivers with Handle to Retrieve Corresponding Peripheral Clock Frequency.

New API to retrieve the peripheral clock frequency: HAL_DTS_GetClockFreq().

Replace Finite Parameter Defines (Including PPP Instances) with Enum Types at HAL Levels.

Finite parameters (including DTS instances) have been converted into enumerated types (enums) at HAL level. This improves code readability, maintainability, and type safety.

Optimize HAL PPP IRQ Handlers by Reordering Processes and Error Management Statements to Prioritize Critical Interrupts

IRQ handler order optimized (critical events first).

Add HAL_PPP Prefix to All HAL Peripheral APIs (Defines, Macros, Types, and Functions).

All HAL DTS functions start with HAL_DTS_.